#!/usr/bin/make -f

include /usr/share/cdbs/1/class/makefile.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

DEB_MAKE_BUILD_TARGET := all -f Makefile.Debian
DEB_MAKE_CHECK_TARGET := test -f Makefile.Debian
DEB_MAKE_CLEAN_TARGET := clean -f Makefile.Debian
DEB_MAKE_INSTALL_TARGET := install -f Makefile.Debian DESTDIR=$(DEB_DESTDIR) DEB_UPSTREAM_VERSION=$(DEB_UPSTREAM_VERSION)
DEB_DH_INSTALL_SOURCEDIR := $(DEB_DESTDIR)

pre-build:: apply-patches
	chmod +x scripts/buildMainHelpIndex.lua
	test -d build || mkdir build 
	cd build && cmake -DOWN_LUA=0 -DCMAKE_SKIP_RPATH=TRUE -DCMAKE_INSTALL_PREFIX=/usr -DTORCH_VERSION=$(DEB_UPSTREAM_VERSION) ../
	lua5.1-policy-apply
	touch $@

clean:: reverse-patches
	lua5.1-policy-apply --reverse
	$(RM) -r build
	$(RM) apply-patches

patch: apply-patches

get-orig-source:
	-uscan --rename --upstream-version 0
	@echo successfully retrieved upstream tarball
